<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
<!--          <a-col :span="24">-->
<!--            <a-form-model-item label="井id" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jingId">-->
<!--              <a-input v-model="model.jingId" placeholder="请输入井id"  ></a-input>-->
<!--            </a-form-model-item>-->
<!--          </a-col>-->
          <a-col :span="24">
            <a-form-model-item label="井名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jm">
              <a-input v-model="model.jm" placeholder="请输入井名"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="目的层顶深" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="mdcdings">
              <a-input v-model="model.mdcdings" placeholder="请输入目的层顶深"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="目的层底深" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="mdcdis">
              <a-input v-model="model.mdcdis" placeholder="请输入目的层底深"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="目的层长度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="mdccd">
              <a-input v-model="model.mdccd" placeholder="请输入目的层长度"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="储厚" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ch">
              <a-input v-model="model.ch" placeholder="请输入储厚"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="渗透率" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="stl">
              <a-input v-model="model.stl" placeholder="请输入渗透率"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="含水饱和度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="hsbhd">
              <a-input v-model="model.hsbhd" placeholder="请输入含水饱和度"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="I类储层厚" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ilcch">
              <a-input v-model="model.ilcch" placeholder="请输入I类储层厚"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="I类储层空隙度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ilcckxd">
              <a-input v-model="model.ilcckxd" placeholder="请输入I类储层空隙度"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="II类储层厚" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="iilcch">
              <a-input v-model="model.iilcch" placeholder="请输入II类储层厚"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="II类储层孔隙度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="iilcckxd">
              <a-input v-model="model.iilcckxd" placeholder="请输入II类储层孔隙度"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="III类储层厚" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="iiilcch">
              <a-input v-model="model.iiilcch" placeholder="请输入III类储层厚"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="III类储层孔隙度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="iiilcckxd">
              <a-input v-model="model.iiilcckxd" placeholder="请输入III类储层孔隙度"  ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'YtsjLjccdztzForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
           jingId: [
              { required: true, message: '请输入井id!'},
           ],
        },
        url: {
          add: "/YtsjLjccdztz/ytsjLjccdztz/add",
          edit: "/YtsjLjccdztz/ytsjLjccdztz/edit",
          queryById: "/YtsjLjccdztz/ytsjLjccdztz/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {

        //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {

      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
         
        })
      },
    }
  }
</script>